﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Menu.aspx.cs" Inherits="Menu" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <%-- <link href="../Styles/MenuAccountTest.css" rel="stylesheet" type="text/css" />--%>
    <link rel="stylesheet" type="text/css" href="ddcolortabs.css" />
    <script src="jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="ddtabmenu.js" type="text/javascript"></script>
    <script type="text/javascript">      
    var baseUrl = "<%= ResolveUrl("~/") %>";
    function ResolveUrl(url) {
        if (url.indexOf("~/") == 0) {
            url = baseUrl + url.substring(2);
        }
        return url;
    }  
    var pourl="<%= ResolveUrl("~/") %>"
    function CheckPoUrl(){
       var tempurl ="~/Main/Inventory/PurchaseOrder.aspx";
       if(tempurl.indexOf("~/")==0)
       {
        tempurl=pourl+tempurl.substring(2);
       }
       return tempurl;
    }
    //$(document).ready(function() 
    //{
        //ddtabmenu.definemenu("ddtabs",0);
    //}); 
        function ShowUrl(NewUrl,ViewUrl)
        {       
          
            var Browser = navigator.appName;
            var _divContext = document.getElementById('divContext');	
            var aAddNew = document.getElementById('aAddNew');	
            var aView = document.getElementById('aView');
            if(NewUrl!=''&& ViewUrl!='')
            {
                aView.style.display = 'block'
                aAddNew.style.display = 'block';
                aAddNew.href = ResolveUrl(NewUrl);
		        aView.href = ResolveUrl(ViewUrl);
		    }
		    else if(NewUrl==''&& ViewUrl!='')
		    {
		        aAddNew.style.display = 'none';
		        aView.href = ResolveUrl(ViewUrl);
		        aView.style.display = 'block';
		    }
		    else if(NewUrl!=''&& ViewUrl=='')
		    {
		        aAddNew.style.display = 'block';
		        aAddNew.href = ResolveUrl(NewUrl);		        
		        aView.style.display = 'none';
		    }
		    //document.body.scrollTop does not work in IE
		    //var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
		    //var scrollLeft = document.body.scrollLeft ? document.body.scrollLeft : document.documentElement.scrollLeft;
            var scrollTop = document.documentElement.scrollTop;
	        var scrollLeft=document.documentElement.scrollLeft; 

             CloseContext();
		    // hide the menu first to avoid an "up-then-over" visual effect		    
		     var divHeight=document.getElementById('divContext').clientHeight;		     
		    _divContext.style.left = event.clientX + scrollLeft+5 + 'px';
		    _divContext.style.top = event.clientY + scrollTop-divHeight + 'px';
		    if (Browser == 'Microsoft Internet Explorer') {
                _divContext.style.display = 'block';
            }
            else {
                _divContext.style.visibility = "visible";
            }            
            		      
		    return true;      
        }         
        function CloseContext()
        {
            var Browser = navigator.appName;
            var _divContext = document.getElementById('divContext');            
	       if (Browser == 'Microsoft Internet Explorer') {
                _divContext.style.display = 'none';
            }
            else {
                _divContext.style.visibility = "hidden";
            }  	        
        }        
        function ClosePopup()
        {
         var t=setTimeout("CloseContext();",2000);
        }         
        $(document).ready(function() {
            switch_tabs($('.defaulttab'));
            $('.ddcolortabs a').click(function() {
                switch_tabs($(this));
                saveState: true
            });           
        });
        function switch_tabs(obj) {
            $('.tabcontent').hide();
            $("#divContext").hide();   
            $('.ddcolortabs a').removeClass("selected");
            $('.ddcolortabs a').css("background", "transparent url(media/menu_bg.png) repeat-x;");
            
            $('.ddcolortabs a').hover( function(){
              $(this).css("background", "transparent url(media/menu_hover.png) repeat-x;")
            },
            function(){
              $(this).css("background", "transparent url(media/menu_bg.png) repeat-x;");
            });
            var id = obj.attr("rel");
            $('#' + id).show();    
            obj.addClass("selected");
            obj.css("background", "transparent url(media/menu_hover.png) repeat-x;");
            
            obj.hover( function(){
              $(this).css("background", "transparent url(media/menu_hover.png) repeat-x;")  
            },
            function(){
              
              $(this).css("background", "transparent url(media/menu_hover.png) repeat-x;")
           });
        } 
        function ShowSubMenu(mainId,NewUrl,ViewUrl,MenuName)
        {
            var strNewUrl= ResolveUrl(ViewUrl);
            var strViewUrl= ResolveUrl(ViewUrl);
        
            $("#"+mainId).hide();
            $("#divContext").show();            
            if(NewUrl!=''&& ViewUrl!='')
            {               
                $("#aAddNew").show();
                $("#aView").show();
                $("#aAddNew").attr("href",ResolveUrl(NewUrl));
                $("#aView").attr("href", ResolveUrl(ViewUrl));
		    }
		    else if(NewUrl==''&& ViewUrl!='')
		    {
		        $("#aAddNew").hide();
                $("#aView").show();                
                $("#aView").attr("href", ResolveUrl(ViewUrl));
		       
		    }
		    else if(NewUrl!=''&& ViewUrl=='')
		    {
		        $("#aAddNew").show();
                $("#aView").hide();	
                $("#aAddNew").attr("href",ResolveUrl(NewUrl));
               	        
		    }
		    $("#spanMenuName").text(MenuName+' :');
		    $("#aBack").click(function() {
		        $('.tabcontent').hide();
                $("#"+mainId).show();
                $("#divContext").hide();  
            });			    	    
        }
             
    </script>
    <script language="javascript" type="text/javascript">
        var sessionTimeout1 = "<%= Session.Timeout %>" ;
        var now = new Date();
        var kickoff = now.setMinutes(now.getMinutes() + parseInt(sessionTimeout1));
        function updateWCTime() 
        {
            now = new Date();
            diff = kickoff - now;
            days = Math.floor(diff / (1000 * 60 * 60 * 24));
            hours = Math.floor(diff / (1000 * 60 * 60));
            mins = Math.floor(diff / (1000 * 60));
            secs = Math.floor(diff / 1000);
            if (hours > 1) {
                hh = hours - days;
                if (hh < 10) {
                    hh = "0" + hh;
                }
            }
            else {
                hh = "00";
            }
            mm = mins - hours * 60;
            if (mm < 10) {
                mm = "0" + mm;
            }
            ss = secs - mins * 60;
            if (ss < 10) {
                ss = "0" + ss;
            } 
            document.getElementById("lbltime").innerHTML ='Session Time Out: '+hh+':'+ mm + ':' + ss;
        }
        setInterval(updateWCTime, 1000);        
        //var time1 = new Date();
        //var TempSecond = 0;
        //var TempMinutes = 0;
        //var timeRefresh;
        //var LoginSecond = time1.getSeconds();
        //timeRefresh = setInterval("TimeCount()", 1000);
        //function TimeCount() {
            //var time = new Date();
            //var Hours = time.getHours();
            //var Minute = time.getMinutes();
            //var Second = time.getSeconds();
            //var sessionTime = '<%=System.Configuration.ConfigurationSettings.AppSettings["SessionWarning"].ToString()%>';
            //var sessionTimePeriod = "<%= Session.Timeout %>";
            //var ConvertHours = parseFloat(sessionTime) / 60;
            //if (parseInt(Hours) < 10) {
                //Hours = "0" + Hours;
            //}
            //if (parseInt(Minute) < 10) {
                //Minute = "0" + Minute;
            //}
            //if (parseInt(Second) < 10) {
                //Second = "0" + Second;
            //}
            //document.getElementById("lbltime").innerHTML = "Session Time Out After: " + Hours + ":" + Minute + ":" + Second;            
        //}
        var sessionTimeoutWarning = '<%=System.Configuration.ConfigurationSettings.AppSettings["SessionWarning"].ToString()%>';
        var sessionTimeout = "<%= Session.Timeout %>";
        var sTimeout = parseInt(sessionTimeoutWarning) * 60 * 1000;
        var timeOnPageLoad = new Date();
        setTimeout('SessionWarning()', sTimeout);
        setTimeout('RedirectToWelcomePage()', parseInt(sessionTimeout) * 60 * 1000);
        function SessionWarning() {
            //minutes left for expiry            
            var minutesForExpiry = (parseInt(sessionTimeout) - parseInt(sessionTimeoutWarning));
            var message = "Your session will expire in another " + minutesForExpiry + " mins! Please Save the data before the session expires";
            alert(message);
            var currentTime = new Date();
            //time for expiry
            var timeForExpiry = timeOnPageLoad.setMinutes(timeOnPageLoad.getMinutes() + parseInt(sessionTimeout));
            //Current time is greater than the expiry time
            if (Date.parse(currentTime) > timeForExpiry) {
                alert("Session expired. You will be redirected to home page");
                window.location = "../Index.aspx";
            }
        }
        function RedirectToWelcomePage() {
            alert("Session expired. You will be redirected to home page");
            window.location = "../Index.aspx";
        }        
    </script>
</head>
<body style="padding: 0 0 0 0; margin: 0 0 0 0;" onload="TimeCount();">
    <form id="form1" runat="server">
    <div>
        <div style="width: 100%; background-color: #88bd6e; height: 97px;">
            <div style="float: left; width: 15%;">
                <table>
                    <tr>
                        <td>
                            <img src="media/logo.png" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lbltime" Style="font-size: 11px; color:#ffffff; font-family: Verdana;" runat="server"></asp:Label>
                        </td>
                    </tr>
                </table>
            </div>
            <div style="float: left; margin-left: 15px; width: 72%;">
                <div id="ddtabs" runat="server" class="ddcolortabs">
                </div>
                <div id="TabContainer" runat="server" class="tabcontainer">
                    <div id="divContext" style="display: none; color: White; margin-top: 5px; font: normal 11px Arial, Verdana, sans-serif;
                        letter-spacing: 1px;" class="subMenu">
                        <span id="spanMenuName" style="font-weight: bold"></span><span id="spanMenuName1"
                            style="font-weight: bold"></span><span id="spanMenuName2" style="font-weight: bold">
                            </span><span id="spanMenuName3" style="font-weight: bold"></span><a id="aAddNew"
                                href="#" style="display: none" class="norm" target="contentframe">Add New</a>
                        <a id="aView" href="#" style="display: none" class="norm" target="contentframe">View</a>
                        <a id="aBack" class="norm" href="#">Back</a>
                    </div>
                </div>
            </div>
            <div style="float: right; width: 10%;">
                <table>
                    <tr>
                        <td>
                            <asp:Label ID="lblSession" runat="server"></asp:Label>
                        </td>
                    </tr>
                </table>
                <table>
                    <tr>
                        <td>
                            <img src="../Images/Logo.gif" width="100px" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td align="center">
                            <asp:HyperLink ID="HypHome" runat="server" ImageUrl="~/Menu/media/home1.png" NavigateUrl="~/Welcome.aspx"
                                Target="contentframe"></asp:HyperLink>
                            <asp:HyperLink ID="hypImg" runat="server" ImageUrl="~/Menu/media/logout1.png" NavigateUrl="~/logout.aspx"
                                Target="_parent"></asp:HyperLink>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="ddcolortabsline" style="clear: both">
            &nbsp;</div>
    </div>
    <asp:GridView ID="grdDisplay" runat="server">
    </asp:GridView>
    </form>
</body>
</html>
